/**
 * @author adagys
 */

package com.eu.chipin.backend.db;

public final class Schema {
	
	public static final String TABLE_TRIPS = "trips";
	public static final String TABLE_MEMBERS = "members";
	public static final String TABLE_PARTICIPANTS = "participants";
	public static final String TABLE_PURCHASES = "purchases"; 
	public static final String TABLE_BUYERS = "buyers"; 
	public static final String TABLE_CHIPPERS = "chippers";
	public static final String TABLE_BALANCE = "balance";
	
	public static final String CHARSET = "utf8";
	
	public static final String SQL_TRIPS = "CREATE TABLE " + TABLE_TRIPS + "(" +
										   "tid INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, " +
										   "name TEXT NOT NULL, " +
										   "timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP" +
										   ");";

	public static final String SQL_PARTICIPANTS = "CREATE TABLE " + TABLE_PARTICIPANTS + "(" +
			 									  "id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, " +
			 									  "tid INTEGER NOT NULL, " +
			 									  "cid INTEGER NOT NULL" +
												  ");";

	public static final String SQL_MEMBERS = "CREATE TABLE " + TABLE_MEMBERS + "(" +
                                          	      "cid INTEGER PRIMARY KEY NOT NULL, " +
                                          	      "name TEXT NOT NULL" +
                                          	      ");";
			 									  
	public static final String SQL_PURCHASES = "CREATE TABLE " + TABLE_PURCHASES + "(" +
											   "pid INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, " +
											   "tid INTEGER NOT NULL, " +
											   "name TEXT NOT NULL, " +
											   "total_sum REAL NOT NULL, " +
											   "timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP" +
											   ");";
	
	public static final String SQL_BUYERS = "CREATE TABLE " + TABLE_BUYERS + "(" +
			   								"bid INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, " +
			   								"pid INTEGER NOT NULL, " +
			   								"cid TEXT NOT NULL, " +
			   								"sum REAL NOT NULL" +
			   								");";

	public static final String SQL_CHIPPERS = "CREATE TABLE " + TABLE_CHIPPERS + "(" +
											  "chid INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, " +
											  "pid INTEGER NOT NULL, " +
											  "cid TEXT NOT NULL, " +
											  "sum REAL NOT NULL, " +
											  "exclude INTEGER DEFAULT 0, " +
											  "additional INTEGER DEFAULT 0" +
											  ");";
	
	public static final String SQL_BALANCE = "CREATE TABLE " + TABLE_BALANCE + "(" +
											 "id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE," +
											 "cid TEXT NOT NULL, " +
											 "tid INTEGER NOT NULL" +
											 "balance REAL" +
											 ");";
}
